/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kungkhies.mvc.kungkhie.search;

import com.kungkhies.services.kungkhie.search.KungkhieSearchService;
import java.util.Map;
import javax.inject.Inject;
import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 *
 * @author clayton
 */
@Controller
public class KungkhieSearchController
{
    private KungkhieSearchService kungkhieSearchService;

    @Autowired
    public KungkhieSearchController(KungkhieSearchService kungkhieSearchService)
    {
        this.kungkhieSearchService = kungkhieSearchService;
    }

    @RequestMapping(value = {"/search"}, method = RequestMethod.GET)
    public String showSearchResultsPage(@RequestParam("searchPhrase") String searchPhrase, Map<String, Object> model)
    {
        model.put("results", kungkhieSearchService.searchKungkhies(searchPhrase));

        return "searchResults";
    }
}
